package com.servicelayer.base;

import java.util.List;

import com.core.protocols.IServiceLayerDelegate;

public abstract class ServiceLayer {

    private IServiceLayerDelegate layerDelegate     = null;
    protected String              selectionCriteria = null;



    public IServiceLayerDelegate getLayerDelegate () {

        return layerDelegate;
    }



    public void setLayerDelegate ( IServiceLayerDelegate delegate ) {

        this.layerDelegate = delegate;
    }



    public String getSelectionCriteria () {

        return this.selectionCriteria;
    }



    public void setSelectionCriteria ( String value ) {

        this.selectionCriteria = value;
    }



    abstract public void performRequestWithFilter ( String predicate );



    protected <T> void performResponse ( List <T> items,
                                         Exception exception ) {

        if ( layerDelegate == null ) {
            System.out.println(String.format("%s.delegate==null", this.getClass().getCanonicalName()));
            return;
        }
        layerDelegate.responseResponseItemsList(items, this, exception);

    };
}
